package com.yingside.net.chat2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) {
        Socket s = null;
        try {
            s = new Socket("192.168.28.131",8888);

            //接收控制台输入的信息
//            BufferedReader br = null;
//            br = new BufferedReader(new InputStreamReader(System.in));

            Scanner input = new Scanner(System.in);

            //从服务器获取信息
            BufferedReader sbr = null;
            sbr = new BufferedReader(new InputStreamReader(s.getInputStream()));

            PrintWriter out = new PrintWriter(s.getOutputStream(),true);

            System.out.println("请开始你的表演:");
            String str = null;
            //循环的从控制台一直接收信息
            String serverBack = null;

            while(true){
                str = input.next();
                out.println(str);

                while((serverBack = sbr.readLine()) != null){
                    System.out.println("serverBack = " + serverBack);
                    break;
                }
            }



        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if(s != null){
                    s.close();
                }

            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
